package com.jic.interaction.JDVOP.controller;

import com.jic.interaction.JDVOP.common.utils.RestResult;
import com.jic.interaction.JDVOP.model.enyity.AfsServicebyCustomerPinPage;
import com.jic.interaction.JDVOP.model.enyity.BizRefundDetailVo;
import com.jic.interaction.JDVOP.model.enyity.CompatibleServiceDetailDTO;
import com.jic.interaction.JDVOP.model.enyity.ComponentExport;
import com.jic.interaction.JDVOP.model.vo.request.*;
import com.jic.interaction.JDVOP.model.vo.request.order.OrderPayRequest;
import com.jic.interaction.JDVOP.service.AfterSaleCommodityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * @description: TODO
 * @author: lixuehui
 * @date: 2020/11/16 10:16
 * @Version 1.0
 */
@RestController
@Slf4j
@RequestMapping("/api/invoice")
@Api(tags = " [售后API接口]")
public class AfterSaleCommodityController {

    @Resource
    AfterSaleCommodityService service;
    /**
     * 校验某订单中某商品是否可以提交售后服务
     * @return
     */
    @PostMapping("/getAvailableNumberComp")
    @ApiOperation(value = "查询可售后商品")
    public RestResult<Integer> getAvailableNumberComp(@RequestBody  AfterSaleCommodityRequest request) throws InvocationTargetException, NoSuchMethodException, UnsupportedEncodingException, IllegalAccessException {
        return service.getAvailableNumberComp(request) ;
    }

    @PostMapping("/getCustomerExpectComp")
    @ApiOperation(value = "根据订单号、商品编号查询支持的服务类型")
    public RestResult<List<ComponentExport>> getCustomerExpectComp(@RequestBody  AfterSaleCommodityRequest request) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        return service.getCustomerExpectComp(request);
    }

    @PostMapping("/getWareReturnJdComp")
    @ApiOperation(value = "根据订单号、商品编号查询支持的商品返回京东方式")
    public RestResult<List<ComponentExport>> getWareReturnJdComp(@RequestBody  AfterSaleCommodityRequest request){
        return service.getWareReturnJdComp(request);
    }

    //发起售后申请 。
    //需要该配送单已经妥投。
    //需要先调用10.3接口校验订单中某商品是否可以提交售后服务
    //需要先调用10.4接口查询支持的服务类型
    //需要先调用10.5接口查询支持的商品返回京东方式
    @PostMapping("/createAfsApply")
    @ApiOperation(value = "发起售后申请")
    public String createAfsApply(@RequestBody CreateAfsApplyRequest request) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {

        return service.createAfsApply(request);
    }
    //如果商品需要逆向发往京东，当选择第三方配送时，使用此接口填写配送信息。接口依赖：
    //需要调用10.6 查询得到服务单号
    //并且有需要补充客户发运信息时调用这个接口
    @PostMapping("/updateSendSku")
    @ApiOperation(value = "填写发运信息")
    public RestResult<String> updateSendSku(@RequestBody UpdateSendSkuRequest request){

        return service.updateSendSku(request);
    }

    @PostMapping("/getServiceListPage")
    @ApiOperation(value = "查询服务单概要")
    public RestResult<AfsServicebyCustomerPinPage> getServiceListPage(@RequestBody ServiceListPageRequest request){

        return service.getServiceListPage(request);
    }

    @PostMapping("/getServiceDetailInfo")
    @ApiOperation(value = "查询服务单明细")
    public RestResult<CompatibleServiceDetailDTO> getServiceDetailInfo(@RequestBody ServiceDetailInfoRequest request){

        return service.getServiceDetailInfo(request);
    }
    @PostMapping("/auditCancel")
    @ApiOperation(value = "取消服务单")
    public RestResult<Boolean> auditCancel(@RequestBody AuditCancelRequest request ){

        return service.auditCancel(request);
    }

    @PostMapping("/getOrderPayByOrderId")
    @ApiOperation(value = "查询退款明细")
    public RestResult<List<BizRefundDetailVo>> getOrderPayByOrderId(@RequestBody OrderPayRequest request ){

        return service.getOrderPayByOrderId(request);
    }


}
